package com.wejoy.video.middle.station.data.domain;

import java.util.Collection;

/**
 * @author admin
 */
public class PageResult {
    /** 页数 */
    private int pageNo;
    /** 总页数 */
    private int pageCount;
    /** 总条数 */
    private int total;
    /** 数据 */
    private Collection<?> rows;
    /** 页大小 */
    private int pageSize;

    public PageResult() {
    }

    public PageResult(int pageNo, int pageSize, int total, Collection<?> rows) {
        this.pageNo = pageNo;
        this.total = total;
        this.rows = rows;
        this.pageSize = pageSize;
        this.pageCount = calcPageCount(total);

    }

    private int calcPageCount(int count) {
        if (pageSize == 0) {
            return 0;
        }
        if (count % pageSize == 0) {
            return count / pageSize;
        } else {
            return count / pageSize + 1;

        }
    }

    public static int getPageCount(int count, int pageSize) {
        if (pageSize == 0) {
            return 0;
        }
        if (count % pageSize == 0) {
            return count / pageSize;
        } else {
            return count / pageSize + 1;
        }
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getPageNo() {
        return pageNo;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }

    public int getPageCount() {
        return pageCount;
    }

    public void setPageCount(int pageCount) {
        this.pageCount = pageCount;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public Collection<?> getRows() {
        return rows;
    }

    public void setRows(Collection<?> rows) {
        this.rows = rows;
    }
}
